package com.mail.controller;

import com.mail.common.DataResult;
import com.mail.service.MailService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/email/mail")
public class EmailController {
    @Resource
    private MailService mailService;

    /**
     * 查询定时任务
     * */
    @GetMapping("/queryTimedMail")
    public DataResult queryTimedMail(@RequestParam Map<String, Object> map){
        String page = (String) map.get("page");
        String limit = (String) map.get("limit");
        if (page.length() == 0 || limit.length() == 0) {
            return DataResult.error("请传入分页参数！");
        }
        if (Long.parseLong(page) < 0 || Long.parseLong(limit) < 0) {
            return DataResult.error("请传入正确的参数！");
        }
        return mailService.queryTimedMail(map);
    }
}
